﻿import QtQuick 2.15
import QtQuick.Controls 2.15

/*
  管理界面
*/

Item {
    id:backGround
    width: screenWidth
    height: 1600

    Rectangle{
        anchors.fill: backGround
        color: "#00BFFF"
        border.width: 5
        border.color: "#F0F8FF"
    }

    onVisibleChanged: {
        if(visible === true)
        {
            Cpp_Connect.pageNumber = 6
        }
    }

    // 左锯45
    property bool leftSaw45: Cpp_Connect.IO_Y4
    // 左锯90
    property bool leftSaw90: Cpp_Connect.IO_Y5
    // 右锯45
    property bool rightSaw45: Cpp_Connect.IO_Y6
    // 右锯90
    property bool rightSaw90: Cpp_Connect.IO_Y7


    // 左电机启动
    property bool leftMechineMode: Cpp_Connect.IO_Y2
    // 右电机启动
    property bool rightMechineMode: Cpp_Connect.IO_Y3
    // 左压料
    property bool leftImpactState: Cpp_Connect.IO_Y12
    // 右压料
    property bool rightImpactState: Cpp_Connect.IO_Y13
    // 外摆拽料
    property bool outswingPullState: Cpp_Connect.IO_Y21
    // 左侧拉料
    property bool leftPullState: Cpp_Connect.IO_Y23
    // 左锯片工进
    property bool leftSaw_GJState: Cpp_Connect.IO_Y10
    // 右锯片工进
    property bool rightSaw_GJState: Cpp_Connect.IO_Y11
    // 料高气缸
    property bool lg_AirState: Cpp_Connect.IO_Y14




    Rectangle{          // 机床调试部分
        anchors.top: backGround.top
        anchors.horizontalCenter: backGround.horizontalCenter
        color: "#00BFFF"
        border.width: 5
        border.color: "#F0F8FF"
        width: backGround.width
        height: 870

        Rectangle{          // 左移按钮
            anchors.left: parent.left
            anchors.leftMargin: 30
            anchors.top: parent.top
            anchors.topMargin: 30
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("← 左移")
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    parent.color = "#ff3606"
                    Cpp_Connect.write_modbus_rtu_Coils("21","1");
                }

                onReleased: {
                    parent.color = "#006cee"
                    Cpp_Connect.write_modbus_rtu_Coils("21","0");
                }
            }
        }

        Rectangle{          // 右移按钮
            anchors.left: parent.left
            anchors.leftMargin: 280
            anchors.top: parent.top
            anchors.topMargin: 30
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("右移 →")
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    parent.color = "#ff3606"
                    Cpp_Connect.write_modbus_rtu_Coils("22","1");
                }

                onReleased: {
                    parent.color = "#006cee"
                    Cpp_Connect.write_modbus_rtu_Coils("22","0");
                }
            }
        }


        Rectangle{          // 复位按钮
            anchors.left: parent.left
            anchors.leftMargin: 520
            anchors.top: parent.top
            anchors.topMargin: 30
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("复 位")
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    parent.color = "#ff3606"
                    Cpp_Connect.write_modbus_rtu_Coils("5","1");
                }

                onReleased: {
                    parent.color = "#006cee"
                    Cpp_Connect.write_modbus_rtu_Coils("5","0");
                }
            }
        }


        Rectangle{          // IO监控
            anchors.left: parent.left
            anchors.leftMargin: 760
            anchors.top: parent.top
            anchors.topMargin: 30
            width: 300
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: "#FF7F50"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 40
                font.bold: true
                text:qsTr("IO监控")
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    parent.color = "#FFFF00"
                }

                onReleased: {
                    parent.color = "#FF7F50"
                    io_MonitorWindow.visible = true
                    managerSettingWindow.visible = false
                }
            }
        }


        Text{
            anchors.left: parent.left
            anchors.leftMargin: 50
            anchors.top: parent.top
            anchors.topMargin: 190
            font.pixelSize: 40
            font.bold: true
            text:qsTr("当前位置")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 280
            anchors.top: parent.top
            anchors.topMargin: 160
            width: 200
            height: 100
            radius: 10
            color: "black"
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id:currentLocation_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                color: "aqua"
                text: Cpp_Connect.currentLocation
            }
        }

        Rectangle{          // 读取电机位置按钮
            anchors.left: parent.left
            anchors.leftMargin: 520
            anchors.top: parent.top
            anchors.topMargin: 160
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("读取电机"+"\n"+"当前位置")
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    parent.color = "#ff3606"
                    Cpp_Connect.write_modbus_rtu_Coils("53","1");
                }

                onReleased: {
                    parent.color = "#006cee"
                    Cpp_Connect.write_modbus_rtu_Coils("53","0");
                }
            }
        }


        Rectangle{          // 打印机设置
            anchors.left: parent.left
            anchors.leftMargin: 760
            anchors.top: parent.top
            anchors.topMargin: 160
            width: 300
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: "#FF7F50"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 40
                font.bold: true
                text:qsTr("打印机设定")
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    parent.color = "#FFFF00"
                }

                onReleased: {
                    parent.color = "#FF7F50"
                    printerSettingWindow.visible = true
                    managerSettingWindow.visible = false
                }
            }
        }

        Rectangle{          // 左电机启动按钮
            anchors.left: parent.left
            anchors.leftMargin: 30
            anchors.top: parent.top
            anchors.topMargin: 300
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color:  leftMechineMode ?  "#6d6d6d" : "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("左电机启动")
                color: leftMechineMode ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    Cpp_Connect.write_modbus_rtu_Coils("11","1");
                }

                onReleased: {
                    Cpp_Connect.write_modbus_rtu_Coils("11","0");
                }
            }
        }

        Rectangle{          // 右电机启动按钮
            anchors.left: parent.left
            anchors.leftMargin: 300
            anchors.top: parent.top
            anchors.topMargin: 300
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color:  rightMechineMode ?  "#6d6d6d" : "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("右电机启动")
                color: rightMechineMode ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    Cpp_Connect.write_modbus_rtu_Coils("12","1");
                }

                onReleased: {
                    Cpp_Connect.write_modbus_rtu_Coils("12","0");
                }
            }
        }

        Rectangle{          // 外摆拽料按钮
            anchors.left: parent.left
            anchors.leftMargin: 560
            anchors.top: parent.top
            anchors.topMargin: 300
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color:  outswingPullState ?  "#6d6d6d" : "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("外摆拽料")
                color: outswingPullState ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    Cpp_Connect.write_modbus_rtu_Coils("171","1");
                }

                onReleased: {
                    Cpp_Connect.write_modbus_rtu_Coils("171","0");
                }
            }
        }

        Rectangle{          // 左侧拉料
            anchors.left: parent.left
            anchors.leftMargin: 820
            anchors.top: parent.top
            anchors.topMargin: 300
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color:  leftPullState ?  "#6d6d6d" : "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("左侧拉料")
                color: leftPullState ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    Cpp_Connect.write_modbus_rtu_Coils("198","1");
                }

                onReleased: {
                    Cpp_Connect.write_modbus_rtu_Coils("198","0");
                }
            }
        }



        Rectangle{          // 左压料按钮
            anchors.left: parent.left
            anchors.leftMargin: 30
            anchors.top: parent.top
            anchors.topMargin: 450
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color:  leftImpactState ?  "#6d6d6d" : "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("左压料")
                color: leftImpactState ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    // parent.color = "#ff3606"
                    Cpp_Connect.write_modbus_rtu_Coils("19","1");
                }

                onReleased: {
                    // parent.color = "#006cee"
                    Cpp_Connect.write_modbus_rtu_Coils("19","0");
                }
            }
        }


        Rectangle{          // 右压料按钮
            anchors.left: parent.left
            anchors.leftMargin: 300
            anchors.top: parent.top
            anchors.topMargin: 450
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color:  rightImpactState ?  "#6d6d6d" : "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("右压料")
                color: rightImpactState ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    // parent.color = "#ff3606"
                    Cpp_Connect.write_modbus_rtu_Coils("20","1");
                }

                onReleased: {
                    // parent.color = "#006cee"
                    Cpp_Connect.write_modbus_rtu_Coils("20","0");
                }
            }
        }

        Rectangle{          // 左锯片工进按钮
            anchors.left: parent.left
            anchors.leftMargin: 30
            anchors.top: parent.top
            anchors.topMargin: 600
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color:  leftSaw_GJState ?  "#6d6d6d" : "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("左锯片工进")
                color: leftSaw_GJState ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    Cpp_Connect.write_modbus_rtu_Coils("17","1");
                }

                onReleased: {
                    Cpp_Connect.write_modbus_rtu_Coils("17","0");
                }
            }
        }


        Rectangle{          // 右锯片工进按钮
            anchors.left: parent.left
            anchors.leftMargin: 300
            anchors.top: parent.top
            anchors.topMargin: 600
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color:  rightSaw_GJState ?  "#6d6d6d" : "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("右锯片工进")
                color: rightSaw_GJState ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    Cpp_Connect.write_modbus_rtu_Coils("18","1");
                }

                onReleased: {
                    Cpp_Connect.write_modbus_rtu_Coils("18","0");
                }
            }
        }

        Rectangle{          // 左摆角45度           
            anchors.left: parent.left
            anchors.leftMargin: 560
            anchors.top: parent.top
            anchors.topMargin: 450
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: leftSaw45 ? "#6d6d6d" :"#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("左摆角45度")
                color: leftSaw45 ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    Cpp_Connect.write_modbus_rtu_Coils("13","1");
                }

                onReleased: {
                    Cpp_Connect.write_modbus_rtu_Coils("13","0");
                }
            }
        }

        Rectangle{          // 右摆角45度           
            anchors.left: parent.left
            anchors.leftMargin: 820
            anchors.top: parent.top
            anchors.topMargin: 450
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: rightSaw45 ? "#6d6d6d" :"#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("右摆角45度")
                color: rightSaw45 ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    Cpp_Connect.write_modbus_rtu_Coils("14","1");
                }

                onReleased: {
                    Cpp_Connect.write_modbus_rtu_Coils("14","0");
                }
            }
        }

        Rectangle{          // 左摆角90度
            anchors.left: parent.left
            anchors.leftMargin: 560
            anchors.top: parent.top
            anchors.topMargin: 600
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: leftSaw90 ? "#6d6d6d" : "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("左摆角90度")
                color: leftSaw90 ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    Cpp_Connect.write_modbus_rtu_Coils("15","1");
                }

                onReleased: {
                    Cpp_Connect.write_modbus_rtu_Coils("15","0");
                }
            }
        }

        Rectangle{          // 右摆角90度
            anchors.left: parent.left
            anchors.leftMargin: 820
            anchors.top: parent.top
            anchors.topMargin: 600
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: rightSaw90 ?  "#6d6d6d" : "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("右摆角90度")
                color: rightSaw90 ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    Cpp_Connect.write_modbus_rtu_Coils("16","1");
                }

                onReleased: {
                    Cpp_Connect.write_modbus_rtu_Coils("16","0");
                }
            }
        }

        Rectangle{          // 吹气阀
            anchors.left: parent.left
            anchors.leftMargin: 30
            anchors.top: parent.top
            anchors.topMargin: 740
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("吹气阀")
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    parent.color = "#ff3606"
                    Cpp_Connect.write_modbus_rtu_Coils("235","1");
                }

                onReleased: {
                    parent.color = "#006cee"
                    Cpp_Connect.write_modbus_rtu_Coils("235","0");
                }
            }
        }

        Rectangle{          // 料高气缸
            anchors.left: parent.left
            anchors.leftMargin: 300
            anchors.top: parent.top
            anchors.topMargin: 740
            width: 220
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color:  lg_AirState ?  "#6d6d6d" : "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("料高气缸")
                color: lg_AirState ? "#00ff00" : "black"
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    Cpp_Connect.write_modbus_rtu_Coils("101","1");
                }

                onReleased: {
                    Cpp_Connect.write_modbus_rtu_Coils("101","0");
                }
            }
        }


        Rectangle{          // 高级设置界面切换按钮
            anchors.left: parent.left
            anchors.leftMargin: 560
            anchors.top: parent.top
            anchors.topMargin: 740
            width: 480
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: "#ff7f50"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("高级设置界面(长按2s)")
            }

            MouseArea{
                anchors.fill: parent                            

                onPressAndHold: {
                    parent.forceActiveFocus()
                    parent.color = "#ffff00"
                    decodeWindow.open()
                }

                onReleased: {
                    parent.color = "#ff7f50"
                }
            }
        }

    }

    ///////////////////////////////////////////////////

    Rectangle{          // 测高部分
        anchors.top: backGround.top
        anchors.topMargin: 865
        anchors.horizontalCenter: backGround.horizontalCenter
        color: "#00BFFF"
        border.width: 5
        border.color: "#F0F8FF"
        width: backGround.width
        height: 160
        visible: Cpp_Connect.AutoObserve_Exist

        Text{
            anchors.left: parent.left
            anchors.leftMargin: 20
            anchors.verticalCenter: parent.verticalCenter
            font.pixelSize: 30
            font.bold: true
            text:qsTr("料高测量值")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 180
            anchors.verticalCenter: parent.verticalCenter
            width: 200
            height: 100
            radius: 10
            color: "black"
            border.width: 1
            border.color: "#F0F8FF"

            Text{           // 料高测量值显示
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                color: "aqua"
                visible: true
                text: Cpp_Connect.LG_observe
            }
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 430
            anchors.verticalCenter: parent.verticalCenter
            width: 200
            height: 100
            radius: 10
            color: "#006cee"
            border.width: 1
            border.color: "#F0F8FF"

            Text{           // 料高误差修正按钮
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                color: "black"
                visible: true
                text:qsTr("料高误差"+"\n"+"  修正")
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    parent.color = "#ff3606"
                }

                onReleased: {
                    parent.color = "#006cee"
                }
            }
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 650
            anchors.verticalCenter: parent.verticalCenter
            width: 200
            height: 100
            radius: 10
            color: Cpp_Connect.lg_observe_state ? "#03ff00" : "#000000"
            border.width: 1
            border.color: "#F0F8FF"

            Text{           // 料高值已固定
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                color: Cpp_Connect.lg_observe_state ? "red" : "aqua"
                visible: true
                text: Cpp_Connect.lg_observe_state ? qsTr("料高值"+"\n"+"测量中") : qsTr("料高值"+"\n"+"已固定")
            }
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 870
            anchors.verticalCenter: parent.verticalCenter
            width: 200
            height: 100
            radius: 10
            color: "#006cee"
            border.width: 1
            border.color: "#F0F8FF"

            Text{           // 料高值已固定
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                color: "black"
                visible: true
                text:qsTr("开始测高")
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.forceActiveFocus()
                    parent.color = "#ff3606"
                    Cpp_Connect.write_modbus_rtu_Coils("108","1");
                }

                onReleased: {
                    parent.color = "#006cee"
                    Cpp_Connect.write_modbus_rtu_Coils("108","0");
                }
            }
        }
    }
///////////////////////////////////////////////////

    Rectangle{          // 测高部分
        anchors.top: backGround.top
        anchors.topMargin: 1020
        anchors.horizontalCenter: backGround.horizontalCenter
        color: "#00BFFF"
        border.width: 5
        border.color: "#F0F8FF"
        width: backGround.width
        height: 580

        Text{
            anchors.left: parent.left
            anchors.leftMargin: 60
            anchors.top: parent.top
            anchors.topMargin: 20
            font.pixelSize: 30
            font.bold: true
            text:qsTr("原点值")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 20
            anchors.top: parent.top
            anchors.topMargin: 70
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id:origin_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.OriginValue
            }

            TextInput{      // 原点输入框
                id:origin_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold_F("210",origin_Input.text)
                    origin_Text.visible = true
                    origin_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    origin_Input.forceActiveFocus()
                    origin_Input.text = origin_Text.text
                    origin_Text.visible = false
                    origin_Input.visible = true
                    origin_Input.selectAll()
                }
            }
        }

        Text{
            anchors.left: parent.left
            anchors.leftMargin: 260
            anchors.top: parent.top
            anchors.topMargin: 20
            font.pixelSize: 30
            font.bold: true
            text:qsTr("定位速度")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 230
            anchors.top: parent.top
            anchors.topMargin: 70
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id:positoinSpeed_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.LocationSpeed
            }

            TextInput{      // 定位速度输入框
                id:positoinSpeed_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold_F("206",positoinSpeed_Input.text)
                    positoinSpeed_Text.visible = true
                    positoinSpeed_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    positoinSpeed_Input.forceActiveFocus()
                    positoinSpeed_Input.text = positoinSpeed_Text.text
                    positoinSpeed_Text.visible = false
                    positoinSpeed_Input.visible = true
                    positoinSpeed_Input.selectAll()
                }
            }
        }


        Text{
            anchors.left: parent.left
            anchors.leftMargin: 470
            anchors.top: parent.top
            anchors.topMargin: 20
            font.pixelSize: 30
            font.bold: true
            text:qsTr("手动速度")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 440
            anchors.top: parent.top
            anchors.topMargin: 70
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id:manualSpeed_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.ManualSpeed
            }

            TextInput{      // 手动速度输入框
                id:manualSpeed_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold_F("1392",manualSpeed_Input.text)
                    manualSpeed_Text.visible = true
                    manualSpeed_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    manualSpeed_Input.forceActiveFocus()
                    manualSpeed_Input.text = manualSpeed_Text.text
                    manualSpeed_Text.visible = false
                    manualSpeed_Input.visible = true
                    manualSpeed_Input.selectAll()
                }
            }
        }


        Text{
            anchors.left: parent.left
            anchors.leftMargin: 660
            anchors.top: parent.top
            anchors.topMargin: 20
            font.pixelSize: 30
            font.bold: true
            text:qsTr("压紧动作时间")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 650
            anchors.top: parent.top
            anchors.topMargin: 70
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id:compactionTime_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.ImpactTime
            }

            TextInput{      // 压紧动作时间输入框
                id:compactionTime_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold_F("1280",compactionTime_Input.text)
                    compactionTime_Text.visible = true
                    compactionTime_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    compactionTime_Input.forceActiveFocus()
                    compactionTime_Input.text = compactionTime_Text.text
                    compactionTime_Text.visible = false
                    compactionTime_Input.visible = true
                    compactionTime_Input.selectAll()
                }
            }
        }

        Text{
            anchors.left: parent.left
            anchors.leftMargin: 870
            anchors.top: parent.top
            anchors.topMargin: 20
            font.pixelSize: 30
            font.bold: true
            text:qsTr("左右吹气时间")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 860
            anchors.top: parent.top
            anchors.topMargin: 70
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id: lrBlowTime_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.LR_Blow_Time
            }

            TextInput{      // 左右吹气时间输入框
                id: lrBlowTime_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold("374",lrBlowTime_Input.text)
                    lrBlowTime_Text.visible = true
                    lrBlowTime_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    lrBlowTime_Input.forceActiveFocus()
                    lrBlowTime_Input.text = lrBlowTime_Text.text
                    lrBlowTime_Text.visible = false
                    lrBlowTime_Input.visible = true
                    lrBlowTime_Input.selectAll()
                }
            }
        }

        Text{
            anchors.left: parent.left
            anchors.leftMargin: 30
            anchors.top: parent.top
            anchors.topMargin: 210
            font.pixelSize: 30
            font.bold: true
            text:qsTr("左锯工进时间")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 20
            anchors.top: parent.top
            anchors.topMargin: 260
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id:leftSawTime_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.LeftSaw_GJTime
            }

            TextInput{      // 左锯工进时间输入框
                id:leftSawTime_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold_F("232",leftSawTime_Input.text)
                    leftSawTime_Text.visible = true
                    leftSawTime_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    leftSawTime_Input.forceActiveFocus()
                    leftSawTime_Input.text = leftSawTime_Text.text
                    leftSawTime_Text.visible = false
                    leftSawTime_Input.visible = true
                    leftSawTime_Input.selectAll()
                }
            }
        }

        Text{
            anchors.left: parent.left
            anchors.leftMargin: 240
            anchors.top: parent.top
            anchors.topMargin: 210
            font.pixelSize: 30
            font.bold: true
            text:qsTr("右锯工进时间")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 230
            anchors.top: parent.top
            anchors.topMargin: 260
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id:rightSawTime_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.RightSaw_GJTime
            }

            TextInput{      // 右锯工进时间输入框
                id:rightSawTime_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold_F("234",rightSawTime_Input.text)
                    rightSawTime_Text.visible = true
                    rightSawTime_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    rightSawTime_Input.forceActiveFocus()
                    rightSawTime_Input.text = rightSawTime_Text.text
                    rightSawTime_Text.visible = false
                    rightSawTime_Input.visible = true
                    rightSawTime_Input.selectAll()
                }
            }
        }

        Text{
            anchors.left: parent.left
            anchors.leftMargin: 450
            anchors.top: parent.top
            anchors.topMargin: 210
            font.pixelSize: 30
            font.bold: true
            text:qsTr("双锯45度补偿")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 440
            anchors.top: parent.top
            anchors.topMargin: 260
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id: doubleSaw45_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.DoubleSaws45_Compensate
            }

            TextInput{      // 双锯45度补偿输入框
                id: doubleSaw45_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold_F("1384",doubleSaw45_Input.text)
                    doubleSaw45_Text.visible = true
                    doubleSaw45_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    doubleSaw45_Input.forceActiveFocus()
                    doubleSaw45_Input.text = doubleSaw45_Text.text
                    doubleSaw45_Text.visible = false
                    doubleSaw45_Input.visible = true
                    doubleSaw45_Input.selectAll()
                }
            }
        }

        Text{
            anchors.left: parent.left
            anchors.leftMargin: 655
            anchors.top: parent.top
            anchors.topMargin: 210
            font.pixelSize: 30
            font.bold: true
            text:qsTr("单独45度补偿")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 650
            anchors.top: parent.top
            anchors.topMargin: 260
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id: singleSaw45_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.SingleSaw45_Compensate
            }

            TextInput{      // 单独45度补偿输入框
                id: singleSaw45_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold_F("396",singleSaw45_Input.text)
                    singleSaw45_Text.visible = true
                    singleSaw45_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    singleSaw45_Input.forceActiveFocus()
                    singleSaw45_Input.text = singleSaw45_Text.text
                    singleSaw45_Text.visible = false
                    singleSaw45_Input.visible = true
                    singleSaw45_Input.selectAll()
                }
            }
        }

        Text{
            anchors.left: parent.left
            anchors.leftMargin: 865
            anchors.top: parent.top
            anchors.topMargin: 210
            font.pixelSize: 30
            font.bold: true
            text:qsTr("45度安全位置")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 860
            anchors.top: parent.top
            anchors.topMargin: 260
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id: safeDistance_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.SafeDistance
            }

            TextInput{      // 45度安全距离输入框
                id: safeDistance_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold_F("1394",safeDistance_Input.text)
                    safeDistance_Text.visible = true
                    safeDistance_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    safeDistance_Input.forceActiveFocus()
                    safeDistance_Input.text = safeDistance_Text.text
                    safeDistance_Text.visible = false
                    safeDistance_Input.visible = true
                    safeDistance_Input.selectAll()
                }
            }
        }

        Text{
            anchors.left: parent.left
            anchors.leftMargin: 30
            anchors.top: parent.top
            anchors.topMargin: 400
            font.pixelSize: 30
            font.bold: true
            text:qsTr("料高检测时间")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 20
            anchors.top: parent.top
            anchors.topMargin: 440
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id: lgDetectionTime_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.LG_Detection_Time
            }

            TextInput{      // 料高检测时间输入框
                id: lgDetectionTime_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold_F("1288",lgDetectionTime_Input.text)
                    lgDetectionTime_Text.visible = true
                    lgDetectionTime_Input.visible = false
                    lgDetectionTime_Input.selectAll()
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    lgDetectionTime_Input.forceActiveFocus()
                    lgDetectionTime_Input.text = lgDetectionTime_Text.text
                    lgDetectionTime_Text.visible = false
                    lgDetectionTime_Input.visible = true
                }
            }
        }

        Text{
            anchors.left: parent.left
            anchors.leftMargin: 240
            anchors.top: parent.top
            anchors.topMargin: 400
            font.pixelSize: 30
            font.bold: true
            text:qsTr("料高磁尺当量")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 230
            anchors.top: parent.top
            anchors.topMargin: 440
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id: lgcc_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.LG_CC_DL
            }

            TextInput{      // 料高磁尺当量输入框
                id: lgcc_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold_F("1290",lgcc_Input.text)
                    lgcc_Text.visible = true
                    lgcc_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    lgcc_Input.forceActiveFocus()
                    lgcc_Input.text = lgcc_Text.text
                    lgcc_Text.visible = false
                    lgcc_Input.visible = true
                    lgcc_Input.selectAll()
                }
            }
        }

        Text{
            anchors.left: parent.left
            anchors.leftMargin: 440
            anchors.top: parent.top
            anchors.topMargin: 400
            font.pixelSize: 30
            font.bold: true
            text:qsTr("电磁阀断电延时")
        }

        Rectangle{
            anchors.left: parent.left
            anchors.leftMargin: 440
            anchors.top: parent.top
            anchors.topMargin: 440
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"

            Text{
                id: dcfddys_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: Cpp_Connect.DCF_OutageDelay
            }

            TextInput{      // 电磁阀断电延时输入框
                id: dcfddys_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false

                onEditingFinished: {
                    Cpp_Connect.write_modbus_rtu_Hold_F("238",dcfddys_Input.text)
                    dcfddys_Text.visible = true
                    dcfddys_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    dcfddys_Input.forceActiveFocus()
                    dcfddys_Input.text = dcfddys_Text.text
                    dcfddys_Text.visible = false
                    dcfddys_Input.visible = true
                    dcfddys_Input.selectAll()
                }
            }
        }

    }


    Popup{
        id: decodeWindow
        width: 650
        height: 870
        anchors.centerIn: backGround
        background: Rectangle{
            color: "gold"
            border.width: 5
            border.color: "#f0f8ff"
        }

        Item{
            id:popupBackGround
            anchors.fill: parent
        }

        Text{
            anchors.top: popupBackGround.top
            anchors.topMargin: 30
            anchors.horizontalCenter: popupBackGround.horizontalCenter
            font.bold: true
            font.pixelSize: 50
            text:qsTr("请输入管理员账号和密码后"+"\n"+"       继续操作")
        }

        Text{
            anchors.left: popupBackGround.left
            anchors.leftMargin: 30
            anchors.top: popupBackGround.top
            anchors.topMargin: 200
            font.bold: true
            font.pixelSize: 30
            text:qsTr("管理员账号")
        }

        Rectangle{
            anchors.left: popupBackGround.left
            anchors.leftMargin: 250
            anchors.top: popupBackGround.top
            anchors.topMargin: 170
            width: 300
            height: 80
            radius: 10

            Text{
                id: adminAccount_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
                text: "admin"
            }

            TextInput{      // 管理员账号输入框
                id: adminAccount_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false
                // text: adminAccount_Text.text

                onEditingFinished: {
                    adminAccount_Text.text = adminAccount_Input.text
                    adminAccount_Text.visible = true
                    adminAccount_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    adminAccount_Input.forceActiveFocus()
                    adminAccount_Input.text = adminAccount_Text.text
                    adminAccount_Text.visible = false
                    adminAccount_Input.visible = true
                    adminAccount_Input.selectAll()
                }
            }
        }

        Text{
            anchors.left: popupBackGround.left
            anchors.leftMargin: 30
            anchors.top: popupBackGround.top
            anchors.topMargin: 360
            font.bold: true
            font.pixelSize: 30
            text:qsTr("管理员密码")
        }

        Rectangle{
            anchors.left: popupBackGround.left
            anchors.leftMargin: 250
            anchors.top: popupBackGround.top
            anchors.topMargin: 330
            width: 300
            height: 80
            radius: 10

            Text{
                id: adminPasswd_Text
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                visible: true
            }

            TextInput{      // 管理员密码输入框
                id: adminPasswd_Input
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                font.italic: true
                maximumLength: 10
                visible: false
                // text: adminPasswd_Text.text

                onEditingFinished: {
                    adminPasswd_Text.text = adminPasswd_Input.text
                    adminPasswd_Text.visible = true
                    adminPasswd_Input.visible = false
                }
            }

            MouseArea{
                anchors.fill: parent

                onClicked: {
                    adminPasswd_Input.forceActiveFocus()
                    adminPasswd_Input.text = adminPasswd_Text.text
                    adminPasswd_Text.visible = false
                    adminPasswd_Input.visible = true
                    adminPasswd_Input.selectAll()
                }
            }
        }


        Rectangle{
            anchors.left: popupBackGround.left
            anchors.leftMargin: 50
            anchors.top: popupBackGround.top
            anchors.topMargin: 560
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("登 录")
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.color = "#ff3606"
                }

                onReleased: {
                    parent.color = "#006cee"
                    parent.forceActiveFocus()
                    if( adminAccount_Text.text === "admin" && adminPasswd_Text.text === "123" )
                    {
                        console.log("密码正确，取消弹窗")
                        decodeWindow.close()
                        advanceSettingWindow.visible = true
                        managerSettingWindow.visible = false
                        // adminAccount_Text.text = ""
                        // adminPasswd_Text.text = ""
                    }
                    else if( adminAccount_Text.text === "" && adminPasswd_Text.text === "" )
                    {
                        warningText.text = qsTr("请输入账号和密码")
                        warningWindow.open()
                    }
                    else
                    {
                        warningText.text = qsTr("密码错误！！")
                        warningWindow.open()
                    }
                }
            }
        }

        Rectangle{
            anchors.right: popupBackGround.right
            anchors.rightMargin: 50
            anchors.top: popupBackGround.top
            anchors.topMargin: 560
            width: 200
            height: 100
            radius: 10
            border.width: 1
            border.color: "#F0F8FF"
            color: "#006cee"

            Text{
                anchors.centerIn: parent
                font.pixelSize: 30
                font.bold: true
                text:qsTr("取 消")
            }

            MouseArea{
                anchors.fill: parent

                onPressed: {
                    parent.color = "#ff3606"
                    // adminAccount_Text.text = ""
                    // adminPasswd_Text.text = ""
                    parent.forceActiveFocus()
                }

                onReleased: {
                    parent.color = "#006cee"
                    decodeWindow.close()
                }
            }
        }

        Popup{
            id:warningWindow
            width: 400
            height: 400
            anchors.centerIn: parent
            background: Rectangle{
                color: "red"
            }

            Text{
                id:warningText
                anchors.centerIn: parent
                font.pixelSize: 40
                font.bold: true
            }
        }



    }



}
